<?php

/**
 * persona form.
 *
 * @package    sistema_itec_new
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class personaAlumnoForm extends personaForm {

    public function configure() {

        parent::configure();

        $this->embedRelations(array(
            'AntecedenteLaboral' => array(
                'considerNewFormEmptyFields' => array('ano_alta', 'cantidad_horas'),
                'noNewForm' => false,
                'newFormLabel' => 'Antecedentes Laborales',
                'newFormClass' => 'antecedenteLaboralForm',
                'newFormClassArgs' => array(array('sf_user' => $this->getOption('sf_user'))),
                'displayEmptyRelations' => false,
                'formClass' => 'antecedenteLaboralForm',
                'formClassArgs' => array(array('ah_add_delete_checkbox' => true)),
                'newFormAfterExistingRelations' => false,
                'formFormatter' => 'Embed',
                'multipleNewForms' => true,
                'newFormsInitialCount' => 1,
                'newFormsContainerForm' => null, // pass BaseForm object here or we will create ahNewRelationsContainerForm
                'newRelationButtonLabel' => '<i class="icon-plus"></i> Agregar otro trabajo',
                'newRelationAddByCloning' => true,
                'newRelationUseJSFramework' => 'jQuery',
                'customEmbeddedFormLabelMethod' => 'getLabelTitle'
            ),
            'Alumno' => array(
                'considerNewFormEmptyFields' => array(),
                'noNewForm' => false,
                'newFormLabel' => 'Alumno',
                'newFormClass' => 'alumnoForm',
                'newFormClassArgs' => array(array('sf_user' => $this->getOption('sf_user'))),
                'displayEmptyRelations' => false,
                'formClass' => 'alumnoForm',
                'formClassArgs' => array(array('ah_add_delete_checkbox' => false)),
                'newFormAfterExistingRelations' => false,
                'formFormatter' => null,
                'multipleNewForms' => false,
                'newFormsContainerForm' => null, // pass BaseForm object here or we will create ahNewRelationsContainerForm
                'customEmbeddedFormLabelMethod' => 'getLabelTitle'
            ),
        ));

        $this->widgetSchema['localidad_id'] = new sfWidgetFormInputHidden(array(), array('value' => 1));
        $this->widgetSchema['fecha_censo'] = new sfWidgetFormInputHidden(array(), array('value' => date('Y-m-d h:i:s', time())));
        $this->widgetSchema['legajo'] = new sfWidgetFormInputHidden();
    }

    protected function doBind(array $values) {
        if (isset($values['Alumno']['new_AlumnoCohorteUnidadFormacion'])
                && isset($values['Alumno']['AlumnoCohorteUnidadFormacion'])) {
            unset($values['Alumno']['new_AlumnoCohorteUnidadFormacion'][0], $this->embeddedForms['Alumno']['new_AlumnoCohorteUnidadFormacion']);
            unset($this->validatorSchema['Alumno']['new_AlumnoCohorteUnidadFormacion']);
        }
        parent::doBind($values);
    }

}
